# -*- coding: utf-8 -*-
import sys,serial,json,time
conffile = open(sys.path[0]+'/config.json','r')

confstr = conffile.read()
conf = json.loads(confstr)
ser = serial.Serial(conf["GpsSerialPort"], conf["GpsBaudRate"], timeout=0.5)
file = open(sys.path[0]+'/GPSCMD.cd','r')
lines = file.readlines()


for line in lines:
    if len(line)>5 and line[0:1]!='#':
        data = bytes.fromhex(line.strip())
        #print(data)
        ser.write(data)
        time.sleep(1)
        #exit()
        if line.strip()=='B5 62 06 09 0D 00 FF FF 00 00 00 00 00 00 FF FF 00 00 03 1B 9A':
            print('wait...')
            time.sleep(4)
print('complete')
